#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
ll l,v;
int t,n,m,p[N],d[N],u[N],a[N],cnt;
struct node{
	int l,r;
}e[N];
bool cmp(node x,node y){return x.r<y.r;}
int lo(ll x){return lower_bound(p+1,p+m+1,x)-p;}
int up(ll x){return upper_bound(p+1,p+m+1,x)-p;}
ll ge(ll v0,ll a,ll b){return v0*v0+2*a*b;}
int f1(ll d,ll u,ll a,int l){
	int r=m,ans=l;
	while(l<=r){
		int mid=(l+r)>>1;
		if(ge(u,a,p[mid]-d)>v*v)ans=mid,l=mid+1;
		else r=mid-1;
	}return ans;
}int f2(ll d,ll u,ll a,int l){
	int r=m,ans=m;
	while(l<=r){
		int mid=(l+r)>>1;
		if(ge(u,a,p[mid]-d)>v*v)ans=mid,r=mid-1;
		else l=mid+1;
	}return ans;
}void work(){
	scanf("%d%d%lld%lld",&n,&m,&l,&v);cnt=0;
	for(int i=1;i<=n;i++)scanf("%d%d%d",&d[i],&u[i],&a[i]);
	for(int i=1;i<=m;i++)scanf("%d",&p[i]);
	sort(p+1,p+m+1);
    for(int i=1;i<=n;i++){
    	if(a[i]<=0){
    		if(u[i]<=v)continue;
    		int t=lo(d[i]);
    		if(t>m)continue;
    		if(ge(u[i],a[i],p[t]-d[i])<=v*v)continue;
    		e[++cnt]=node{t,f1(d[i],u[i],a[i],t)};
    	}else{
    		if(d[i]>p[m])continue;
    		if(ge(u[i],a[i],p[m]-d[i])<=v*v)continue;
    		e[++cnt]=node{f2(d[i],u[i],a[i],lo(d[i])),m};
    	}
    }sort(e+1,e+cnt+1,cmp);int ans=0,la=-1;
    for(int i=1;i<=cnt;i++){if(e[i].l>la)la=e[i].r,ans++;}
    printf("%d %d\n",cnt,m-ans);
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&t);
	while(t--)work();
	return 0;
}